#! /usr/bin/env python
# -*- coding: utf-8 -*-

# *************************************************************
#  Copyright (c) Huoty - All rights reserved
#
#      Author: Huoty <sudohuoty@gmail.com>
#  CreateTime: 2016-10-07 21:42:32
# *************************************************************

"""Sevice Base"""

from ..utils import json_dumps
from .botapi import *


class JsonResponse(object):
    """定义响应内容结构"""

    status = {
        # code: msg
        12000: "successful",
        12001: "not exist key",
        12002: "not exist user",
        12003: "decrypt data error",
        12004: "invalid parameter",
        12005: "incorrect data format",
        12006: "",
        12050: "server internal error"
    }

    def __init__(self, code=12000, data=None):
        self.code = code
        self.data = data

    def to_dict(self):
        return {"code": self.code, "msg": self.status[self.code], "data": self.data}

    def to_json(self):
        return json_dumps(self.to_dict())


def api_scheduler(msg, userid=None):
    answer = __import__("random").choice([turing, qizhi, qingyunke, moli])(msg)
    return answer


# Script starts from here

if __name__ == "__main__":
    pass
